--- @coding utf8

local ServerEntity = {
    _CLASS_NAME = "xxx"
}

-- local ServerEntityMeta = {}
-- ServerEntityMeta.__call = function(self, ...)
--     local obj = ServerEntity:_constructor(...)
--     return obj
-- end
-- setmetatable(ServerEntity, ServerEntityMeta)

function ServerEntity:new()
    local obj = {
        pkey = 0
    }
    setmetatable(obj, {
        __index = self
    })
    return obj
end

function ServerEntity:on_init_prop_done()
    print("on_init_prop_done")
end

function ServerEntity:init_prop_from_data()
    print("init_prop_from_data")
end

function ServerEntity:dirty_persist()  -- delay
    print("dirty_persist")
end

function ServerEntity:insert_self_to_db()
    print("insert_self_to_db")
end

function ServerEntity:load_self_from_db()
    print("load_self_from_db")
end

local function _load_entity_from_db()
end

local _on_load_from_db_done = function()
end

local _on_load_many_from_db_done = function()
end

--return ServerEntity

-- print(ServerEntity)
-- for k, v in pairs(ServerEntity) do
--     print(k, v)
-- end
local entity = ServerEntity:new()
print("entity=", entity)
print(#entity)
print("entity members:")
for k, v in pairs(entity) do
    print(type(k), k, type(v), v)
end
entity:load_self_from_db()

entity1 = ServerEntity:new()
print(entity._CLASS_NAME, entity1._CLASS_NAME)
entity._CLASS_NAME = "aaa"
entity1._CLASS_NAME = "bbb"
print(entity._CLASS_NAME, entity1._CLASS_NAME)